$(function() {

	// Default values
	var commentsBtn = $("a.comments-btn"),
		comments = $("div#comments"),
		commentsHeader = $("div#promotion-comments h2"),
		dateBtn = $("a#date-btn")
		slider = $("ul#promotion-slider"),
		list = $("div#promotions-list"),
		listContainer = $("div#promotions-list-container"),
		countList = list.children('div').length, 
		items = countList - 10,
		customUp = '<div class="list-buttons"><a href="#" class="custom-up">up</a></div><!-- .list-buttons -->',
		customDown = '<div class="list-buttons"><a href="#" class="custom-down">down</a></div><!-- .list-buttons -->';

	// Comments Button
	commentsBtn.click(function(e) {
		commentsHeader.toggleClass('comments-header-border');
		commentsBtn.toggleClass('closed');
		comments.slideToggle();
		e.preventDefault();
	});
	

	// Main Slider
	slider.anythingSlider({
		theme : 'main',
		hashTags : false,
		buildNavigation : false,
		buildStartStop : false,
		infiniteSlides : false
	});
	


	// Sidebar List
	if ( countList > 10 ) {

		listContainer.prepend(customUp);		
		listContainer.append(customDown);

		list.anythingSlider({
			theme : 'list',
			vertical : true,
			hashTags : false,
			buildArrows: false,
			buildNavigation : false,
			buildStartStop : false,
			infiniteSlides : false
		});

		var customBtnUp = $("a.custom-up"),
			customBtnDown = $("a.custom-down");


		customBtnUp.click(function(e){
			if ( list.data('AnythingSlider').currentPage > 1 )
			{
				list.data('AnythingSlider').goBack();
			}				
			e.preventDefault();
		});

		customBtnDown.click(function(e){
			if ( list.data('AnythingSlider').currentPage <= items )
			{
				list.data('AnythingSlider').goForward();
			}						
			e.preventDefault();
		});
	}

	
});
